package 笔试题.pdd;

import java.util.Scanner;

public class t1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] matrix = new int[n][n];
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                if (n % 2 == 0) {
                    if (i - j == 0 || i + j == n - 1) {
                        matrix[i][j] = 0;
                    } else if (i + j < n - 1 && j >= n / 2) {
                        matrix[i][j] = 1;
                    } else if (i - j < 0 && j < n / 2) {
                        matrix[i][j] = 2;
                    } else if (i - j > 0 && i < n / 2) {
                        matrix[i][j] = 3;
                    } else if (i + j < n - 1 && i >= n / 2) {
                        matrix[i][j] = 4;
                    } else if (i + j > n - 1 && j < n / 2) {
                        matrix[i][j] = 5;
                    } else if (i - j > 0 && j >= n / 2) {
                        matrix[i][j] = 6;
                    } else if (i - j < 0 && i >= n / 2) {
                        matrix[i][j] = 7;
                    } else if (i + j > n - 1 && i < n / 2) {
                        matrix[i][j] = 8;
                    }
                } else {
                    if (i - j == 0 || i + j == n - 1) {
                        matrix[i][j] = 0;
                    } else if (i == n / 2 || j == n / 2) {
                        matrix[i][j] = 0;
                    } else if (i + j < n - 1 && j >= n / 2) {
                        matrix[i][j] = 1;
                    } else if (i - j < 0 && j < n / 2) {
                        matrix[i][j] = 2;
                    } else if (i - j > 0 && i < n / 2) {
                        matrix[i][j] = 3;
                    } else if (i + j < n - 1 && i > n / 2) {
                        matrix[i][j] = 4;
                    } else if (i + j > n - 1 && j < n / 2) {
                        matrix[i][j] = 5;
                    } else if (i - j > 0 && j > n / 2) {
                        matrix[i][j] = 6;
                    } else if (i - j < 0 && i > n / 2) {
                        matrix[i][j] = 7;
                    } else if (i + j > n - 1 && i < n / 2) {
                        matrix[i][j] = 8;
                    }
                }
            }
        }
        for (int[] ints : matrix) {
            for (int j = 0; j < matrix[0].length; j++) {
                System.out.print(ints[j] + " ");
            }
            System.out.println();
        }
    }
}
